<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="item,index in tabs" @click="changeIndex(index)">{{item.title}}</li>
        </ul>
        <div>
            {{tabs[nowIndex].content}}
            {{nowIndex}}
        </div>
    </div>

    <script>
        const app = new Vue({
            el: "#app",
            data: {
                nowIndex: 0,
                tabs: [
                    {
                        id: 1,
                        title: "html",
                        content: "这是html"
                    },
                    {
                        id: 2,
                        title: "css",
                        content: "这是css"
                    }, {
                        id: 3,
                        title: "js",
                        content: "这是js"
                    }
                ]
            },
            methods: {
                changeIndex(index) {
                    this.nowIndex = index;
                }
            }
        })
    </script>
</body>

</html>